package com.league.zjxn.main.access

import androidx.core.widget.addTextChangedListener
import com.league.zjxn.R
import com.league.zjxn.jetpack.vmodel.AccessViewModel
import com.module.lemlin.http.Status
import com.module.lemlin.owner.OwnerAbstractFragment
import com.module.lemlin.owner.OwnerViewModeFragment
import kotlinx.android.synthetic.main.fragment_access_login_code.*
import kotlinx.android.synthetic.main.fragment_access_update_code.*

class UpdateCodeFragment : OwnerViewModeFragment<AccessViewModel>() {

    companion object {
        fun newInstance(): UpdateCodeFragment {
            return UpdateCodeFragment()
        }
    }

    override fun viewModel(): AccessViewModel {
        return createViewModel(requireActivity())
    }

    override val layoutResId: Int
        get() = R.layout.fragment_access_update_code

    override fun initView() {

        etUpdateCodePhone.addTextChangedListener { editable ->
            editable?.let { viewModel.mMapUpdatePass["mobile"] = it.toString() }
            tvUpdateCodeSubmit.isEnabled =
                !editable.isNullOrEmpty() && !etUpdateCodeCode.text.isNullOrEmpty()
        }
        etUpdateCodeCode.addTextChangedListener { editable ->
            editable?.let { viewModel.mMapUpdatePass["code"] = it.toString() }
            tvUpdateCodeSubmit.isEnabled =
                !editable.isNullOrEmpty() && !etUpdateCodePhone.text.isNullOrEmpty()
        }
    }
}